﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TFDP.Common;
using System.ComponentModel;
using Microsoft.VisualStudio.Shell.Interop;
using System.Runtime.InteropServices;

namespace TFDP.SimpleProcessor
{
    [ComVisible(true)]
    [ClassInterface(ClassInterfaceType.None)]
    public class SimpleProcessorProperties : CommonProperties, IExtenderType
    {
        #region Provided Properties
        public const string GenerateTriggersProperty = "GenerateTriggers";

        [DisplayName("Generate triggers")]
        [Description("true if triggers should be generated for this table")]
        [Category("T4 Generator Extensions")]
        [DefaultValue(false)]
        public bool GenerateTriggers
        {
            get
            {
                string value = GetPropertyValue(GenerateTriggersProperty);
                bool generateTriggers = false;

                Boolean.TryParse(value, out generateTriggers);

                return generateTriggers;
            }
            set
            {
                SetPropertyValue(GenerateTriggersProperty, value.ToString());
            }
        }

        public const string GenerateCrudProceduresProperty = "GenerateCrudProcedures";

        [DisplayName("Generate CRUD procedures")]
        [Description("true if CRUD procedures should be generated for this table")]
        [Category("T4 Generator Extensions")]
        [DefaultValue(false)]
        public bool GenerateCrudProcedures
        {
            get
            {
                string value = GetPropertyValue(GenerateCrudProceduresProperty);

                bool generateCrudProcedures = false;

                Boolean.TryParse(value, out generateCrudProcedures);

                return generateCrudProcedures;
            }
            set
            {
                SetPropertyValue(GenerateCrudProceduresProperty, value.ToString());
            }
        }

        public const string GenerateHistoryTableProperty = "GenerateHistoryTable";

        [DisplayName("Generate History table")]
        [Description("true if a history table should be generated for this table")]
        [Category("T4 Generator Extensions")]
        [DefaultValue(false)]
        public bool GenerateHistoryTable
        {
            get
            {
                string value = GetPropertyValue(GenerateHistoryTableProperty);

                bool generateHistoryTable = false;

                Boolean.TryParse(value, out generateHistoryTable);

                return generateHistoryTable;
            }
            set
            {
                SetPropertyValue(GenerateHistoryTableProperty, value.ToString());
            }
        }

        public const string GenerateDataAccessLayerProperty = "GenerateDataAccessLayer";

        [DisplayName("Generate DataAccessLayer")]
        [Description("true if the DataAccessLayer should be generated for this table")]
        [Category("T4 Generator Extensions")]
        [DefaultValue(false)]
        public bool GenerateDataAccessLayer
        {
            get
            {
                string value = GetPropertyValue(GenerateDataAccessLayerProperty);

                bool generateDataAccessLayer = false;

                Boolean.TryParse(value, out generateDataAccessLayer);

                return generateDataAccessLayer;
            }
            set
            {
                SetPropertyValue(GenerateDataAccessLayerProperty, value.ToString());
            }
        }
        #endregion
    }
}
